import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/utils/input_formatter_tools.dart';

import 'down_button_form.dart';
import 'form_edit_status_inherited_widget.dart';
import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class TitleCurrencyPriceInputForm extends StatelessWidget {
  final String currency;
  final String title;
  final TextEditingController controller;
  final FocusNode focusNode;
  final VoidCallback onChangeCurrency;
  final double leftPadding;
  final double rightPadding;

  const TitleCurrencyPriceInputForm(
      {Key key,
      this.title,
      this.currency,
      this.controller,
      this.focusNode,
      this.onChangeCurrency,
      this.leftPadding,
      this.rightPadding})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
            color: aceGrayColor,
            width: getDp(0.5),
          )),
          color: Colors.white),
      padding: EdgeInsets.only(
        left: leftPadding ?? getDp(35),
        right: rightPadding ?? getDp(35),
        top: getDp(10),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            title,
            style: TextStyle(
              color: aceDarkGrayColor,
              fontSize: getSp(16),
              fontWeight: FontWeight.w400,
              height: 1,
            ),
          ),
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              DownButtonForm(
                padding: EdgeInsets.zero,
                title: currency,
                onTap: onChangeCurrency,
              ),
              AppSpaces.w10,
              Expanded(
                child: FormStatusWidget(
                  builder: (enable) => TextField(
                    scrollPadding: EdgeInsets.zero,
                    decoration: InputDecoration(
                        contentPadding: EdgeInsets.zero,
                        border: InputBorder.none,
                        hintText: '0.00',
                        hintStyle: TextStyle(
                          color: aceGrayColor,
                          fontSize: getSp(24),
                          fontWeight: FontWeight.w700,
                          height: 24 / 24,
                        )),
                    keyboardType:
                        TextInputType.numberWithOptions(decimal: true),
                    inputFormatters: [
                      doubleLimit2InputFormatter,
                    ],
                    style: TextStyle(
                      color: enable ? aceBlueColor : aceBlackColor,
                      fontSize: getSp(24),
                      fontWeight: FontWeight.w700,
                      height: 24 / 24,
                    ),
                    enabled: enable,
                    controller: controller,
                    focusNode: focusNode,
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
